package homework;

import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        String username="yyds";
        int password=123456;
        for (int i = 0; i < 3; i++) {
          if ( login(username,password)){
              System.out.println("登录成功");
              break;
          }else{
              System.out.println("登录失败，还有"+(2-i)+"次机会");
          }
        }
    }
    public static boolean login(String username,int password){
        Scanner scanner=new Scanner(System.in);
        System.out.println("用户名");
        String um=scanner.nextLine();
        System.out.println("密码");
        int ps=scanner.nextInt();
        return (um.equals(username)&&ps==password);
    }
}
